import {reqBanners, reqCategoryList,reqFloors} from "@/api";

const state={
    categoryList:[],
    //轮播图
    bannerList:[],
    floorList:[]
}
const mutations={
    CATEGORYLIST(state,categoryList){
     state.categoryList=categoryList
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList=bannerList
    },
    GETFLOORLIST(state,floorList){
        state.floorList=floorList
    }
}
const actions={
    //通过API，向服务器发请求，获取服务器
    async categoryList({commit}){
    let result =await reqCategoryList()
        if(result.code==200){
            commit("CATEGORYLIST",result.data)
        }
    },
    async getBannerList({commit}){
        let result =await reqBanners()
        if(result.code==200){
            commit("GETBANNERLIST",result.data)
        }
    },
    async getFloorList({commit}){
        let result =await reqFloors()
        if(result.code==200){
            commit("GETFLOORLIST",result.data)
        }
    }

}
const getters={}

export default {
    state,mutations,actions,getters
}